let fetch = require("../../utils/fetch");
let mta = require('../../utils/mta_analysis.js');
let app = getApp();
Page({
    data: {
        num: '85',
        imageUrl: app.globalData.imageUrl,
        isShow: false,
        shopList: [],
        totalDiscountAmount: '',
        consumeAmount: '',
        goodsDiscountAmount: '',
        voucherAount: '',
        nickName: '',
        logoList: [],
        

    },

    onLoad: function(options) {
        this.setData({
            nickName: getApp().globalData.userInfo.nickName
        })
    },

    onReady: function() {
        console.log('onReady')
    },
    onShow: function() {
        this.getMaiXiangShops();
        this.getMaiXiangLogo();
        this.getMaiXiangSaveInfo();
    },
    onHide: function() {},
    onUnload: function() {

    },
    showAllSaves: function() {
        this.setData({
            isShow: true
        })
    },
    hideAction: function() {
        this.setData({
            isShow: false
        })
    },
    getMaiXiangShops: function() {
        var _self = this;
        wx.request({
            url: getApp().globalData.baseUrl + '/applet/maixiang/getMaixiangShopAndTerm.do',
            header: getApp().globalData.header,
            success: function(res) {
                if (res.data.code == 200) {
                    console.log("****1****")
                    console.log(res)
                    _self.setData({
                        shopList: res.data.obj
                    })

                } else {

                }
            }
        })
    },
    getMaiXiangSaveInfo: function() {
        var _self = this;
        wx.request({
            url: getApp().globalData.baseUrl + '/applet/maixiang/getDetailOfDiscount.do',
            header: getApp().globalData.header,
            success: function(res) {
                if (res.data.code == 200) {

                    console.log("****2****")
                    console.log(res)
                    _self.setData({
                        totalDiscountAmount: res.data.obj.totalDiscountAmount,
                        consumeAmount: res.data.obj.consumeAmount,
                        goodsDiscountAmount: res.data.obj.goodsDiscountAmount,
                        voucherAount: res.data.obj.voucherAount

                    })
                } else {

                }
            }
        })
    },

    getMaiXiangLogo: function() {
        var _self = this;
        wx.request({
            url: getApp().globalData.baseUrl + '/applet/maixiang/getPrivilegeLogo.do',
            header: getApp().globalData.header,
            success: function(res) {
                if (res.data.code == 200) {
                    console.log("****3****")
                    console.log(res)
                    _self.setData({
                        logoList: res.data.obj
                    })

                } else {

                }
            }
        })
    }


})